package com.lanou3g.hw0518.study;

/**
 * If there are no bugs, it was created by Chen FengYao on 2018/5/21;
 * Otherwise, I don't know who created it either
 */

public class TestThreadLocal {
    public static void main(String[] args) throws InterruptedException {
        ThreadLocal<String> threadLocal = new ThreadLocal<>();

        threadLocal.set("HAHA");

        new Thread(){
            @Override
            public void run() {
                threadLocal.set("啦啦啦啦");
                String a = threadLocal.get();
                System.out.println(getName()
                        +"::"+a);
            }
        }.start();

        Thread.sleep(1000);

        String string =threadLocal.get();
        System.out.println(Thread.currentThread().getName()
                +"::" + string);
    }
}
